<template>
	<div class="movelist">
		<a v-for="move in movelist" @click="goTo(move)">
			<div class="pic">
				<img :src="move.images.medium">
			</div>
			<p>{{move.title}}</p>
		</a>
	</div>
</template>

<script>
export default {
	data() {
		return {
			movelist:[]
		};
	},
	mounted() {
		this.$emit('setNavTitle',['豆瓣高评电影排行榜',1]);
		this.$http.jsonp("https://douban.uieee.com/v2/movie/top250").then((res) => {
			this.movelist=res.data.subjects;
			console.log(this.movelist);
			res=null;
		}).catch((err) => {
			console.log("http error:" + err);
		});
	},
	methods:{
		goTo(item){
			console.log(item);
			sessionStorage.setItem('moveinfo',JSON.stringify(item));
			this.$router.push({
				path:'/moveinfo',
				name:'moveinfo'
			})
		}
	}
}
</script>

<style lang="css" scoped>
	.movelist{display: flex;flex-wrap: wrap;}
	.movelist a{flex-grow: 1;width: 310px;margin: 10px 0;}
	p{color:#333;display: inline-block;}
</style>